package com.ttg.service;


import com.ttg.pojo.BatchProfitPojo;
import com.ttg.pojo.SyncInfoDTO;
import com.ttg.utils.connection.HttpUploadFile;
import com.ttg.utils.connection.TTGHttpClientException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

@Service
public class BatchProfitService extends HttpBaseService {

    private static final Logger logger= LoggerFactory.getLogger(BatchProfitService.class);

    public SyncInfoDTO testBatchProfit(String URL, BatchProfitPojo batchProfitPojo) throws TTGHttpClientException {
        List<HttpUploadFile> uploadFiles = new ArrayList<HttpUploadFile>();
        File batchFile   = batchProfitPojo.getFile();
        HttpUploadFile       uploadFile  = new HttpUploadFile(batchProfitPojo.getFileParameterName(),batchFile.getName(), batchFile,
                null);

        uploadFiles.add(uploadFile);

        SyncInfoDTO t = (SyncInfoDTO) this.sendBatchInfo(URL, batchProfitPojo.getAllParameters(), uploadFiles, 1,
                false, SyncInfoDTO.class);

        logger.debug("test:{}", t);

        return t;
    }
}
